import React, { Component } from 'react'

export default class AddTodo extends Component {
    constructor (props) {
        super(props)
        this.state = {
            text: ''
        }
    }
  render() {
    return (
      <div>
        <input value={this.state.text} onChange={this.changeValue}/>
        <button onClick={this.handleClick}>add</button>
      </div>
    )
  }
  handleClick = () => {
      this.props.addList(this.state.text)
      this.setState({
          text: ''
      })
  }
  changeValue = (e) => {
      this.setState({
          text: e.target.value
      })
  }
}
